package com.tourism.controller;

import com.tourism.entity.Line;
import com.tourism.entity.Ticket;
import com.tourism.service.TicketService;
import com.tourism.util.common.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description
 * @Author z
 * @Date 2021-04-28 23:42
 */
@Controller
@RequestMapping("/ticket")
public class TicketController {


    @Autowired
    private TicketService ticketService;

    /**
     * 新增门票
     *
     * @param ticket
     * @return
     */
    @PostMapping("/addTicket")
    @ResponseBody
    public Response addCustomLine(@RequestBody Ticket ticket) {
        return Response.success(ticketService.addTicket(ticket));

    }
    /**
     * 修改门票
     *
     * @param ticket
     * @return
     */
    @PostMapping("/updateTicket")
    @ResponseBody
    public Response updateTicket(@RequestBody Ticket ticket) {
        return Response.success(ticketService.updateTicket(ticket));

    }

    /**
     * 根据id查询门票信息
     *
     * @param id
     * @return
     */
    @GetMapping("/getTicketById")
    @ResponseBody
    public Ticket getTicketById(Long id) {
        return ticketService.getTicketById(id);
    }


    /**
     * 根据id删除门票信息
     *
     * @param id
     * @return
     */
    @DeleteMapping("/deleteTicketById")
    @ResponseBody
    public Response deleteTicketById(Long id) {
        return Response.success(ticketService.deleteTicketById(id));

    }

    /**
     * 查询门票列表
     *
     * @return
     */
    @GetMapping("/getAllTicket")
    @ResponseBody
    public List<Ticket> getAllTicket(String name, Long attractionId) {
        return ticketService.getAllTicket(name, attractionId);
    }
}
